package com.tmans.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class PreControllerInterceptor implements HandlerInterceptor {
	
	private Logger log = Logger.getLogger(this.getClass());
	
	private final static String aster   = "*********************************************************";
	private final static String crlf = "\r\n";
	
//	Controller 수행전
	public boolean preHandle(HttpServletRequest request,HttpServletResponse response, Object handler) throws Exception {

		String method = request.getMethod();
		String uri= request.getRequestURI();
		String remoteIp = request.getRemoteAddr() == null ?"":request.getRemoteAddr();
		
		log.info(crlf+crlf+aster+crlf				+
				"[Controller Info]"         +crlf	+
				aster                       +crlf   +
				"[Controller : "+uri+"]"	+crlf	+
				"[Method     : "+method+"]"      +crlf   +
				"[remoteIp   : "+remoteIp+"]"  +crlf   +
				aster+crlf+crlf
				);
		
		

		
		
		
		
		return true;
	}

//	Controller 수행완료
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
//		log.info("||||||||||||||||||||||||||||||||||||| Controller 수행완료");

	}

//	View 완료
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
//		log.info("||||||||||||||||||||||||||||||||||||| View 완료");

	}

}
